﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;

namespace EcoSystem
{
    /// <summary>
    /// 报表及接口分类配置管理
    /// </summary>
    [RemoteService]
    [Area("Report")]
    [Route("api/Platform/reportCategoryConfig")]
    public class ReportCategoryConfigController : EcoSystemController, IReportCategoryConfigAppService
    {
        private readonly IReportCategoryConfigAppService _service;
        public ReportCategoryConfigController(IReportCategoryConfigAppService service)
        {
            _service = service;
        }

        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="input">分页参数</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PagedResultDto<ReportCategoryConfigDto>> GetListAsync(GetReportCategoryConfigInput input)
        {
            return await _service.GetListAsync(input);
        }

        /// <summary>
        /// 不分页查询
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        [Route("all")]
        public async Task<ListResultDto<ReportCategoryConfigDto>> GetAllAsync(GetReportCategoryConfigInput input)
        {
            return await _service.GetAllAsync(input);
        }

        /// <summary>
        /// 获取某条记录
        /// </summary>
        /// <param name="id">主键ID</param>
        /// <returns></returns>
        [HttpGet]
        [Route("{id}")]
        public async Task<ReportCategoryConfigDto> GetAsync(Guid id)
        {
            return await _service.GetAsync(id);
        }


        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="input">参数</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ReportCategoryConfigDto> CreateAsync(CreateOrUpdateReportCategoryConfigDto input)
        {
            return await _service.CreateAsync(input);
        }


        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="id">主键ID</param>
        /// <param name="input">参数</param>
        /// <returns></returns>
        [HttpPut]
        [Route("{id}")]
        public async Task<ReportCategoryConfigDto> UpdateAsync(Guid id, CreateOrUpdateReportCategoryConfigDto input)
        {
            return await _service.UpdateAsync(id, input);
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id">主键ID</param>
        /// <returns></returns>
        [HttpDelete]
        [Route("{id}")]
        public async Task DeleteAsync(Guid id)
        {
            await _service.DeleteAsync(id);
        }

        /// <summary>
        /// 获取资源目录树
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        [Route("trees")]
        public async Task<List<ReportCategoryConfigTreeDto>> GetTreeAsync(GetReportCategoryTreeInput input)
        {
            return await _service.GetTreeAsync(input);
        }
    }
}
